package mysql;

import java.sql.*;

public class Connect {
	
	static Connection con;
	
	//java와 mysql간의 연결(Connection)을 return하는 메서드
	public static Connection getConnection(){
		String url = "jdbc:mysql://localhost:3306/test";
		String user = "root";
		String pw = "1234";
		try {
			// import시키기. 원할때 하는 동적 import
			Class.forName("com.mysql.jdbc.Driver");
			con=DriverManager.getConnection(url,user,pw);
			System.out.println("연결 성공"+con);
		} catch (Exception e) {
			System.out.println("연결 실패"+con);
			e.printStackTrace();
		}
		return con;
	}
	
	public static void main(String[] args) {
		getConnection();
	}

}
